using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pipeline : MonoBehaviour {

	public Vector3 speed;
	public Vector2 range;

	// Use this for initialization
	void Start () {
		Init();

	}

	float t = 0;
	
	// Update is called once per frame
	void Update () {
		transform.position -= new Vector3(0.25f * speed.x * Time.deltaTime, speed.y, speed.z);
		t += Time.deltaTime;
        if (t > 6.6f)
        {
			t = 0;
			this.Init();
        }
	}

	public void Init()
	{
		float y = Random.Range(range.x, range.y);
		transform.position = new Vector3(4.66f, y, 0);
	}
}
